package com.crayon.cardbiz.entry.item;

import java.util.Arrays;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.crayon.cardbiz.R;
import com.crayon.util.GDB;

public class FragmentChildItemPhotos extends ListFragment {

	int mNum=0;
	public static FragmentChildItemPhotos newInstance(int num) {
		FragmentChildItemPhotos f = new FragmentChildItemPhotos();

		// Supply num input as an argument.
		Bundle args = new Bundle();
		args.putInt("num", num);
		f.setArguments(args);

		return f;
	}

	/**
	 * When creating, retrieve this instance's number from its arguments.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mNum = getArguments() != null ? getArguments().getInt("num") : 1;
	}

	/**
	 * The Fragment's UI is just a simple text view showing its
	 * instance number.
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
		View tv = v.findViewById(R.id.text);
		((TextView)tv).setText("Fragment #" + mNum);
		return v;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		setListAdapter(new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1, Arrays.asList("ddd","ddd")));
	}

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		Log.i("FragmentList", "Item clicked: " + id);
	}

	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		if(getListAdapter()!=null){
			if(getListAdapter() instanceof ArrayAdapter){
				((ArrayAdapter)getListAdapter()).notifyDataSetChanged();
			}
			getView().postInvalidate();
		}
		super.onResume();
	}
	
	



}

